package com.antler.smt.portal.controller;

import com.antler.smt.portal.annotation.OperateCut;
import com.antler.smt.request.admin.GetSupplierListReq;
import com.antler.smt.request.portal.MemberReq;
import com.antler.smt.response.admin.GetSupplierListResp;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.SupplierService;
import com.antler.smt.utils.LogUtil;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 寻找优质加工厂
 *
 * @author zhangyi
 * @date 2018/4/16 17:40
 */
@RestController
@RequestMapping("/excellentSupplier")
@Api(description = "寻找优质服务商接口")
public class ExcellentSupplierController extends BaseController{

    /**
     * 日志
     */
    public static Logger log = LogUtil.get();

    @Resource
    private SupplierService supplierService;

    /**
     *  查询优质加工厂
     *
     * @param request 查询实体
     * @return
     */
    @PostMapping("/getExcellentSupplier")
    @ApiOperation(value = "查询优质加工厂", httpMethod = "POST")
    @OperateCut(operationContent = "查询优质加工厂")
    public Result<GetSupplierListResp> getExcellentSupplier(@RequestBody GetSupplierListReq request){
        Result result = null;
        result = supplierService.selectExcellentSupplier(request);
        return result;
    }

    /**
     *  查询优质加工厂通过昵称
     *
     * @param request 查询实体
     * @return
     */
    @PostMapping("/selectExcellentSupplierByNickName")
    @ApiOperation(value = "查询优质加工厂通过昵称", httpMethod = "POST")
    @OperateCut(operationContent = "查询优质加工厂")
    public Result<GetSupplierListResp> selectExcellentSupplierByNickName(@RequestBody MemberReq request){

        DataValidator.isNull(request,"会员实体必填！");

        Result result = null;
        result = supplierService.selectExcellentSupplierByNickName(request);
        return result;
    }
}
